#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym_Div_2;
static Symbol sym_Mul_2;
static Symbol sym_Sub_2;
static Symbol sym_Add_2;
static Symbol sym_Int_1;
static Symbol sym_Num_1;
static Symbol sym__2;
static Symbol sym_Nil_0;
static void init_module_constructors (void)
{
sym_Div_2 = ATmakeSymbol("Div", 2, ATfalse);
ATprotectSymbol(sym_Div_2);
sym_Mul_2 = ATmakeSymbol("Mul", 2, ATfalse);
ATprotectSymbol(sym_Mul_2);
sym_Sub_2 = ATmakeSymbol("Sub", 2, ATfalse);
ATprotectSymbol(sym_Sub_2);
sym_Add_2 = ATmakeSymbol("Add", 2, ATfalse);
ATprotectSymbol(sym_Add_2);
sym_Int_1 = ATmakeSymbol("Int", 1, ATfalse);
ATprotectSymbol(sym_Int_1);
sym_Num_1 = ATmakeSymbol("Num", 1, ATfalse);
ATprotectSymbol(sym_Num_1);
sym__2 = ATmakeSymbol("", 2, ATfalse);
ATprotectSymbol(sym__2);
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
}
static void init_module_constant_terms (void)
{
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm div_0_0 (StrSL sl, ATerm t);
ATerm mul_0_0 (StrSL sl, ATerm t);
ATerm subt_0_0 (StrSL sl, ATerm t);
ATerm add_0_0 (StrSL sl, ATerm t);
ATerm io_wrap_1_0 (StrSL sl, StrCL q_9, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
static ATerm u_71 (StrSL sl, ATerm t);
static ATerm lifted0 (StrSL sl, ATerm t);
static ATerm t_71 (StrSL sl, StrCL v_71, ATerm t);
ATerm red_0_0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure z_71 = { &(red_0_0) , sl };
StrCL lifted1_cl = &(z_71);
t = io_wrap_1_0(sl, lifted1_cl, t);
if((t == NULL))
goto fail4 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail4 :
--__tracing_table_counter;
return(NULL);
}
ATerm red_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "red_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
sl_funs(1);
{
struct str_closure y_71 = { &(u_71) , &(frame) };
StrCL u_71_cl = &(y_71);
sl_init_fun(0, u_71_cl);
t = t_71(&(frame), u_71_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static ATerm u_71 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "u_71";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm trm0 = t;
ATerm trm1 = t;
ATerm t_69 = NULL,u_69 = NULL,v_69 = NULL,w_69 = NULL,x_69 = NULL,y_69 = NULL;
if(match_cons(t, sym_Add_2))
{
ATerm trm2 = ATgetArgument(t, 0);
if(match_cons(trm2, sym_Int_1))
{
t_69 = ATgetArgument(trm2, 0);
}
else
goto label3 ;
{
ATerm trm3 = ATgetArgument(t, 1);
if(match_cons(trm3, sym_Int_1))
{
u_69 = ATgetArgument(trm3, 0);
}
else
goto label3 ;
}
}
else
goto label3 ;
w_69 = t;
t = (ATerm) ATmakeAppl(sym__2, t_69, u_69);
t = add_0_0(sl_up(sl), t);
if((t == NULL))
goto label3 ;
v_69 = t;
t = w_69;
y_69 = t;
t = v_69;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label3 ;
x_69 = t;
t = y_69;
t = (ATerm) ATmakeAppl(sym_Int_1, x_69);
goto label2 ;
label3 :
t = trm1;
{
ATerm trm4 = t;
ATerm z_69 = NULL,a_70 = NULL,b_70 = NULL,c_70 = NULL,d_70 = NULL,e_70 = NULL;
if(match_cons(t, sym_Add_2))
{
ATerm trm5 = ATgetArgument(t, 0);
if(match_cons(trm5, sym_Num_1))
{
z_69 = ATgetArgument(trm5, 0);
}
else
goto label4 ;
{
ATerm trm6 = ATgetArgument(t, 1);
if(match_cons(trm6, sym_Num_1))
{
a_70 = ATgetArgument(trm6, 0);
}
else
goto label4 ;
}
}
else
goto label4 ;
c_70 = t;
t = (ATerm) ATmakeAppl(sym__2, z_69, a_70);
t = add_0_0(sl_up(sl), t);
if((t == NULL))
goto label4 ;
b_70 = t;
t = c_70;
e_70 = t;
t = b_70;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label4 ;
d_70 = t;
t = e_70;
t = (ATerm) ATmakeAppl(sym_Num_1, d_70);
goto label2 ;
label4 :
t = trm4;
{
ATerm trm7 = t;
ATerm f_70 = NULL,g_70 = NULL,h_70 = NULL,i_70 = NULL,j_70 = NULL,k_70 = NULL;
if(match_cons(t, sym_Sub_2))
{
ATerm trm8 = ATgetArgument(t, 0);
if(match_cons(trm8, sym_Int_1))
{
f_70 = ATgetArgument(trm8, 0);
}
else
goto label5 ;
{
ATerm trm9 = ATgetArgument(t, 1);
if(match_cons(trm9, sym_Int_1))
{
g_70 = ATgetArgument(trm9, 0);
}
else
goto label5 ;
}
}
else
goto label5 ;
i_70 = t;
t = (ATerm) ATmakeAppl(sym__2, f_70, g_70);
t = subt_0_0(sl_up(sl), t);
if((t == NULL))
goto label5 ;
h_70 = t;
t = i_70;
k_70 = t;
t = h_70;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label5 ;
j_70 = t;
t = k_70;
t = (ATerm) ATmakeAppl(sym_Int_1, j_70);
goto label2 ;
label5 :
t = trm7;
{
ATerm trm10 = t;
ATerm l_70 = NULL,m_70 = NULL,n_70 = NULL,o_70 = NULL,p_70 = NULL,q_70 = NULL;
if(match_cons(t, sym_Sub_2))
{
ATerm trm11 = ATgetArgument(t, 0);
if(match_cons(trm11, sym_Num_1))
{
l_70 = ATgetArgument(trm11, 0);
}
else
goto label6 ;
{
ATerm trm12 = ATgetArgument(t, 1);
if(match_cons(trm12, sym_Num_1))
{
m_70 = ATgetArgument(trm12, 0);
}
else
goto label6 ;
}
}
else
goto label6 ;
o_70 = t;
t = (ATerm) ATmakeAppl(sym__2, l_70, m_70);
t = subt_0_0(sl_up(sl), t);
if((t == NULL))
goto label6 ;
n_70 = t;
t = o_70;
q_70 = t;
t = n_70;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label6 ;
p_70 = t;
t = q_70;
t = (ATerm) ATmakeAppl(sym_Num_1, p_70);
goto label2 ;
label6 :
t = trm10;
{
ATerm trm13 = t;
ATerm r_70 = NULL,s_70 = NULL,t_70 = NULL,u_70 = NULL,w_70 = NULL,x_70 = NULL;
if(match_cons(t, sym_Mul_2))
{
ATerm trm14 = ATgetArgument(t, 0);
if(match_cons(trm14, sym_Int_1))
{
r_70 = ATgetArgument(trm14, 0);
}
else
goto label7 ;
{
ATerm trm15 = ATgetArgument(t, 1);
if(match_cons(trm15, sym_Int_1))
{
s_70 = ATgetArgument(trm15, 0);
}
else
goto label7 ;
}
}
else
goto label7 ;
u_70 = t;
t = (ATerm) ATmakeAppl(sym__2, r_70, s_70);
t = mul_0_0(sl_up(sl), t);
if((t == NULL))
goto label7 ;
t_70 = t;
t = u_70;
x_70 = t;
t = t_70;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label7 ;
w_70 = t;
t = x_70;
t = (ATerm) ATmakeAppl(sym_Int_1, w_70);
goto label2 ;
label7 :
t = trm13;
{
ATerm trm16 = t;
ATerm y_70 = NULL,z_70 = NULL,a_71 = NULL,b_71 = NULL,d_71 = NULL,e_71 = NULL;
if(match_cons(t, sym_Mul_2))
{
ATerm trm17 = ATgetArgument(t, 0);
if(match_cons(trm17, sym_Num_1))
{
y_70 = ATgetArgument(trm17, 0);
}
else
goto label8 ;
{
ATerm trm18 = ATgetArgument(t, 1);
if(match_cons(trm18, sym_Num_1))
{
z_70 = ATgetArgument(trm18, 0);
}
else
goto label8 ;
}
}
else
goto label8 ;
b_71 = t;
t = (ATerm) ATmakeAppl(sym__2, y_70, z_70);
t = mul_0_0(sl_up(sl), t);
if((t == NULL))
goto label8 ;
a_71 = t;
t = b_71;
e_71 = t;
t = a_71;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label8 ;
d_71 = t;
t = e_71;
t = (ATerm) ATmakeAppl(sym_Num_1, d_71);
goto label2 ;
label8 :
t = trm16;
{
ATerm trm19 = t;
ATerm f_71 = NULL,g_71 = NULL,h_71 = NULL,i_71 = NULL,k_71 = NULL,l_71 = NULL;
if(match_cons(t, sym_Div_2))
{
ATerm trm20 = ATgetArgument(t, 0);
if(match_cons(trm20, sym_Int_1))
{
f_71 = ATgetArgument(trm20, 0);
}
else
goto label9 ;
{
ATerm trm21 = ATgetArgument(t, 1);
if(match_cons(trm21, sym_Int_1))
{
g_71 = ATgetArgument(trm21, 0);
}
else
goto label9 ;
}
}
else
goto label9 ;
i_71 = t;
t = (ATerm) ATmakeAppl(sym__2, f_71, g_71);
t = div_0_0(sl_up(sl), t);
if((t == NULL))
goto label9 ;
h_71 = t;
t = i_71;
l_71 = t;
t = h_71;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label9 ;
k_71 = t;
t = l_71;
t = (ATerm) ATmakeAppl(sym_Int_1, k_71);
goto label2 ;
label9 :
t = trm19;
{
ATerm m_71 = NULL,n_71 = NULL,o_71 = NULL,p_71 = NULL,r_71 = NULL,s_71 = NULL;
if(match_cons(t, sym_Div_2))
{
ATerm trm22 = ATgetArgument(t, 0);
if(match_cons(trm22, sym_Num_1))
{
m_71 = ATgetArgument(trm22, 0);
}
else
goto label1 ;
{
ATerm trm23 = ATgetArgument(t, 1);
if(match_cons(trm23, sym_Num_1))
{
n_71 = ATgetArgument(trm23, 0);
}
else
goto label1 ;
}
}
else
goto label1 ;
p_71 = t;
t = (ATerm) ATmakeAppl(sym__2, m_71, n_71);
t = div_0_0(sl_up(sl), t);
if((t == NULL))
goto label1 ;
o_71 = t;
t = p_71;
s_71 = t;
t = o_71;
t = t_71(sl, sl_fun_cl(0, sl), t);
if((t == NULL))
goto label1 ;
r_71 = t;
t = s_71;
t = (ATerm) ATmakeAppl(sym_Num_1, r_71);
goto label2 ;
}
}
}
}
}
}
}
label2 :
;
goto label0 ;
label1 :
t = trm0;
goto label0 ;
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail3 :
--__tracing_table_counter;
return(NULL);
}
static ATerm t_71 (StrSL sl, StrCL v_71, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "t_71";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
sl_funs(1);
sl_init_fun(0, v_71);
{
struct str_closure w_71 = { &(lifted0) , &(frame) };
StrCL lifted0_cl = &(w_71);
t = SRTS_all(sl_up(sl), lifted0_cl, t);
if((t == NULL))
goto fail1 ;
t = cl_fun(v_71)(cl_sl(v_71), t);
if((t == NULL))
goto fail1 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
t = t_71(sl_up(sl), sl_fun_cl(0, sl), t);
if((t == NULL))
goto fail2 ;
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail2 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 10));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(div_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("div_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(mul_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("mul_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(subt_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("subt_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(add_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("add_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(u_71);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("u_71", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(t_71);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("t_71", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(red_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("red_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
